package cn.wjssl.test.thread;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.concurrent.CountDownLatch;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class TaskTest {

    @Autowired
    private ThreadService taskService;

    @Test
    public void test() throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(1); // 用于等待异步任务完成
        taskService.myThreadPoolTaskTest(latch);
        latch.await(); // 等待任务完成
    }
}
